GitHub 复制仓库 |
您所在的位置:网站首页 › github 复制仓库 › GitHub 复制仓库 |
要复制存储库而不对其进行复制,可以运行特殊克隆命令,然后镜像推送到新仓库。 在复制仓库和和推送到仓库的新副本或镜像之前,必须在 GitHub 上创建新仓库。 在以下示例中,exampleuser/new-repository 或 exampleuser/mirrored 是镜像。 镜像仓库 打开 Git Bash。 创建仓库的裸克隆。 $ git clone --bare https://github.com/exampleuser/old-repository.git 镜像推送至新仓库。 $ cd old-repository.git $ git push --mirror https://github.com/exampleuser/new-repository.git 删除您之前创建的临时本地仓库。 $ cd .. $ rm -rf old-repository.git 镜像包含 Git Large File Storage 对象的仓库。 打开 Git Bash。 创建仓库的裸克隆。 将示例用户名替换为拥有仓库的个人或组织的名称,并将示例仓库名称替换为要复制的仓库的名称。 $ git clone --bare https://github.com/exampleuser/old-repository.git 导航到刚克隆的仓库。 $ cd old-repository.git 拉取仓库的 Git Large File Storage 对象。 $ git lfs fetch --all 镜像推送至新仓库。 $ git push --mirror https://github.com/exampleuser/new-repository.git 将仓库的 Git Large File Storage 对象推送至镜像。 $ git lfs push --all https://github.com/exampleuser/new-repository.git 删除您之前创建的临时本地仓库。 $ cd .. $ rm -rf old-repository.git 镜像其他位置的仓库如果要镜像其他位置的仓库,包括从原始位置获取更新,可以克隆镜像并定期推送更改。 打开 Git Bash。 创建仓库的裸镜像克隆。 $ git clone --mirror https://github.com/exampleuser/repository-to-mirror.git 设置到镜像的推送位置。 $ cd repository-to-mirror.git $ git remote set-url --push origin https://github.com/exampleuser/mirrored与裸克隆一样,镜像的克隆包括所有远程分支和标记,但每次获取时都会覆盖所有本地引用,因此它始终与原始仓库相同。 设置推送 URL 可简化至镜像的推送。 如需更新镜像,请获取更新和推送。 $ git fetch -p origin $ git push --mirror |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |